home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / clearvue.mst < prev    next >
Text File  |  1994-10-13  |  10KB  |  342 lines

  1. '**************************************************************************
  2. '*
  3. '* Clearvue.MST - Clear Vue Runtime Setup Script
  4. '*
  5. '* CUSTOMIZING ClearVue.MST
  6. '*
  7. '* For a simple Setup routine, you just need to assign values to the 
  8. '* series of variables following the heading "Setup Variables". This
  9. '* script also provides for the following more-advanced options, which
  10. '* are supported by subroutines located later in this script:
  11. '*
  12. '* Option                                         See Subroutine
  13. '* ------------------------------------------     ---------------------
  14. '* Install more than one .MVB file                ModifyIni
  15. '* Install Help title                             ModifyIni
  16. '* Install custom DLLs                            ModifyIni
  17. '* Install multiple Program Manager items         ModifyProgramManager
  18. '* Display a custom icon with the ProgMan item    ModifyProgramManager
  19. '* Install custom fonts                           RegisterCustomFonts
  20. '* Install Video for Windows runtime files        RegisterDrivers
  21. '*
  22. '* Each customization note starts with the heading CUSTOMIZATION.
  23. '*
  24. '**************************************************************************
  25.     
  26.     '' Global variables
  27.  
  28.     GLOBAL TitleShortName$
  29.     GLOBAL TitleLongName$
  30.     GLOBAL MVBFileName$
  31.     GLOBAL PromptForPath%
  32.     GLOBAL DefaultPath$
  33.     GLOBAL ProgManGroup$
  34.     GLOBAL ProgManItem$
  35.  
  36.     '' ****************************************************************
  37.     '' ** Setup Variables
  38.     '' ****************************************************************
  39.  
  40.     '' Set the following string to a short form of the title name
  41.     '' (for example, "Gallery")
  42.     
  43.     TitleShortName$ = "ClearVue"
  44.     
  45.     '' Set the following string to a long form of the title name
  46.     '' (for example, "Viewer 2.0 Gallery")
  47.     
  48.     TitleLongName$ = "Clear Vue"
  49.         
  50.     '' Set the following variable to the name of the MVB file, without 
  51.     '' the filename extension (for example, "GALLERY")
  52.         
  53.     VUEFileName$ = "ClearVue"
  54.         
  55.     '' The following variable determines whether Setup prompts the user
  56.     '' to specify a directory in which to install title files. (Files
  57.     '' to be installed on the hard disk must be listed in the TITLE.INF 
  58.     '' file under the [Installed Title Files] section.) Specify one of
  59.     '' the following values:
  60.     ''
  61.     '' 0    Install title files in the Windows directory (default setting).
  62.     ''      This is an appropriate setting if you have a limited number
  63.     ''      of files to copy (for example, a single custom icon or DLL).
  64.     ''
  65.     '' 1    Display a dialog box to prompt the user for a directory in 
  66.     ''      which to install files
  67.         
  68.     PromptForPath% = 0
  69.         
  70.     '' If you have specified 1 in PromptForPath%, set the following 
  71.     '' variable to the default path that will be displayed in the dialog
  72.     '' box (for example, "C:\GALLERY").
  73.         
  74.     DefaultPath$ = ""
  75.     
  76.     '' Set the following variable to the name of the program manager 
  77.     '' group you would like to create (for example, "Viewer 2.0 Gallery")
  78.         
  79.     ProgManGroup$ = "ClearVue"
  80.     
  81.     '' Set the following variable to the caption of the program manager 
  82.     '' item for your title (for example, "Gallery")
  83.         
  84.     ProgManItem$ = "ClearVue"
  85.     
  86.     '***********************************************************************
  87.     '** Mainline
  88.     '***********************************************************************
  89.  
  90.     GLOBAL CUIDLL$
  91.  
  92.     '' Include files
  93.     '$INCLUDE 'setupapi.inc'
  94.     
  95.     '' Custom UI dll
  96.     CUIDLL$ = "mscuistf.dll"
  97.     
  98.     '' Dialog ID's
  99.     CONST DESTPATH      = 1000
  100.     CONST APPHELP       = 2000
  101.     CONST TOOBIG        = 3000
  102.     CONST BADPATH       = 4000
  103.     CONST SUCCESS       = 700
  104.     
  105.     '' Bitmap ID
  106.     CONST LOGO = 1
  107.     
  108.     '' Functions and subroutines
  109.     DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  110.     DECLARE FUNCTION GetTitleDir (szDefault$) AS STRING
  111.     DECLARE FUNCTION CopyFiles(szTitleDir$) AS INTEGER
  112.     DECLARE SUB ModifyProgramManager
  113.     DECLARE SUB ShowSuccess
  114.     
  115.     '' The following statement turns size checking off. Set it to scmOnFatal 
  116.     '' to enable size checking, where Setup will compare the disk file size 
  117.     '' with the INF file size and report an error if they are not the same.
  118.     
  119.     i% = SetSizeCheckMode(scmOff)
  120.     
  121.     '' Set the title and banner bitmap. You must rebuild MSCUISTF.DLL to 
  122.     '' alter the banner bitmap.
  123.     
  124.     SetTitle "Clear Vue Setup"
  125.     SetBitmap CUIDLL$, LOGO 
  126.     
  127.     '' Read in the INF file.
  128.     
  129.     ReadInfFile GetSymbolValue("STF_CWDDIR") + "clearvue.INF"
  130.     
  131.     '' Decide where to put title files
  132.     IF PromptForPath% = 1 THEN
  133.         szTitleDir$ = GetTitleDir(DefaultPath$)
  134.         IF szTitleDir$ = "" THEN
  135.             GOTO QUIT
  136.         ENDIF
  137.     ELSE
  138.         szTitleDir$ = GetWindowsDir()
  139.     ENDIF   
  140.     
  141.     '' Copy files
  142.     IF CopyFiles(szTitleDir$) = 0 THEN
  143.         GOTO QUIT
  144.     ENDIF
  145.     
  146.     '' Modify Program Manager
  147.     ModifyProgramManager    
  148.     
  149.     '' Success dialog
  150.     ShowSuccess
  151.     
  152.     '' Now start the title
  153.  
  154.     RUN "ClearVue.exe ", NOWAIT
  155.  
  156. QUIT:
  157.     
  158.     END
  159.     
  160.  
  161. '*************************************************************************
  162. '** Purpose:
  163. '**     Prompts the user for a path for the title files
  164. '** Arguments:
  165. '**     szDefault$ - default path
  166. '** Returns:
  167. '**     New valid path name, or "" if the user quit.
  168. '*************************************************************************
  169.  
  170. FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
  171.  
  172.     SetSymbolValue "String", TitleShortName$
  173.     SetSymbolValue "EditTextIn", szDefault$
  174.     SetSymbolValue "EditFocus", "ALL"
  175.  
  176.     GETPATH:
  177.  
  178.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
  179.  
  180.     IF sz$ = "CONTINUE" THEN
  181.         szTitleDir$ = GetSymbolValue("EditTextOut")
  182.         IF IsDirWritable(szTitleDir$) = 0 THEN
  183.  
  184.             BADPATH:
  185.  
  186.             sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
  187.             IF sz$ = "REACTIVATE" THEN
  188.                 GOTO BADPATH
  189.             END IF
  190.             UIPop 1
  191.             GOTO GETPATH
  192.         END IF
  193.         UIPop 1
  194.         CreateDir szTitleDir$, cmoNone
  195.  
  196.     ELSEIF sz$ = "REACTIVATE" THEN
  197.         GOTO GETPATH
  198.  
  199.     ELSE
  200.         szTitleDir$ = ""
  201.  
  202.     END IF
  203.  
  204.     GetTitleDir = szTitleDir$
  205.  
  206. END FUNCTION
  207.  
  208.  
  209. '*************************************************************************
  210. '** Purpose:
  211. '**     Copies the files in the INF file
  212. '** Arguments:
  213. '**     szTitleDir$ - destination directory for the title files
  214. '** Returns
  215. '**     1 if files were copied, 0 otherwise
  216. '*************************************************************************
  217.  
  218. FUNCTION CopyFiles(szTitleDir$) STATIC AS INTEGER
  219.  
  220.     '' Add for Windows Section files to the copy list
  221.     AddSectionFilesToCopyList "Clear Vue Files", MakePath(GetSymbolValue("STF_SRCDIR"),"ClearVue"), GetWindowsDir()
  222.     
  223.     
  224.     '' Check size
  225.     szExtras$ = "Extra"
  226.     szCosts$ = "Costs"
  227.     szNeededs$ = "Neededs"
  228.     FOR i% = 1 TO 26 STEP 1
  229.         AddListItem szExtras$, "0"
  230.     NEXT i%
  231.     
  232.     '' Get amount of space required
  233.     StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
  234.     
  235.     '' Put up a message if there is not enough space
  236.     FOR i% = 1 TO 26 STEP 1
  237.         IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
  238.     
  239.             SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
  240.             SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
  241.     
  242.             TOOBIG:
  243.     
  244.             sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
  245.             IF sz$ = "REACTIVATE" THEN
  246.                 GOTO TOOBIG
  247.             END IF
  248.             UIPop 1
  249.             CopyFiles = 0
  250.             GOTO DONTCOPY
  251.         END IF
  252.     NEXT i%
  253.     
  254.     '' Copy the files
  255.     CopyFilesInCopyList
  256.     
  257.     CopyFiles = 1
  258.  
  259. DONTCOPY:
  260.  
  261. END FUNCTION
  262.  
  263.  
  264. '*************************************************************************
  265. '** Purpose:
  266. '**     Puts up a success dialog
  267. '*************************************************************************
  268.  
  269. SUB ShowSuccess STATIC
  270.  
  271.     SUCCESS:
  272.     
  273.     SetSymbolValue "String1", TitleShortName$
  274.     sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
  275.     IF sz$ = "REACTIVATE" THEN
  276.         GOTO SUCCESS
  277.     END IF
  278.     UIPop 1
  279.     
  280. END SUB
  281.  
  282.  
  283. '*************************************************************************
  284. '** Purpose:
  285. '**     Appends a file name to the end of a directory path,
  286. '**     inserting a backslash character as needed.
  287. '** Arguments:
  288. '**     szDir$  - full directory path (with optional ending "\")
  289. '**     szFile$ - filename to append to directory
  290. '** Returns:
  291. '**     Resulting fully qualified path name.
  292. '*************************************************************************
  293.  
  294. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  295.     IF szDir$ = "" THEN
  296.         MakePath = szFile$
  297.     ELSEIF szFile$ = "" THEN
  298.         MakePath = szDir$
  299.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  300.         MakePath = szDir$ + szFile$
  301.     ELSE
  302.         MakePath = szDir$ + "\" + szFile$
  303.     END IF
  304. END FUNCTION
  305.  
  306.  
  307.  
  308. '*************************************************************************
  309. '** Purpose:
  310. '**     Creates program manager entries for the title
  311. '*************************************************************************
  312.  
  313. SUB ModifyProgramManager STATIC
  314.  
  315.     '' Create the program manager group
  316.  
  317.     CreateProgmanGroup ProgmanGroup$, "", cmoNone
  318.     ShowProgmanGroup ProgmanGroup$, 1, cmoNone
  319.     
  320.     '' Create an entry for the title
  321.      
  322.     CreateProgmanItem ProgmanGroup$, ProgmanItem$, "clearvue.exe ","", cmoOverwrite
  323.     
  324.     '' CUSTOMIZATION: 
  325.     ''
  326.     '' To create additional Program Manager items, copy the preceding 
  327.     '' statement for each additional item, substituting the appropriate
  328.     '' name for the VUEFileName$ variable.
  329.     ''
  330.     '' To display a custom icon with the Program Manager item, specify
  331.     '' the icon filename with the fourth parameter (this parameter is 
  332.     '' currently an empty string, ""). The following example specifies 
  333.     '' an icon with the same filename as the .exe file:
  334.     ''
  335.     '' CreateProgmanItem ProgmanGroup$, ProgmanItem$, "clearvue.exe " + MakePath(GetSymbolValue("STF_SRCDIR"), VUEFileName$ + ".exe"), MakePath(GetSymbolValue("STF_SRCDIR"), VUEFileName$ + ".ICO"), cmoOverwrite
  336.  
  337. END SUB
  338.  
  339.  
  340.  
  341.  
  342.